import React, {useCallback} from 'react';
import {
  View,
  Text,
  StyleSheet,
  NativeModules,
  Dimensions,
  TouchableWithoutFeedback,
} from 'react-native';
import {useSelector, useDispatch} from 'react-redux';
import PatIcon from '../../base/PatIcon';
import {useNavigation} from '@react-navigation/native';
import Colors from '../../../utils/Colors';
import {useTranslation} from 'react-i18next';
const HEIGHT = NativeModules.StatusBarManager.HEIGHT;
const windowWidth = Dimensions.get('window').width;

const SettingTop = ({title}) => {
  const navigation = useNavigation();
  const goBack = useCallback(() => {
    navigation.goBack();
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [navigation]);
  return (
    <View style={styles.homeTop}>
      <TouchableWithoutFeedback onPress={goBack}>
        <View style={styles.bell}>
          <PatIcon name="error" size={14} color={Colors.patFontColor} />
        </View>
      </TouchableWithoutFeedback>
      <View style={styles.free_ship}>
        <Text style={styles.title}>{title}</Text>
      </View>
    </View>
  );
};

const styles = StyleSheet.create({
  homeTop: {
    paddingTop: HEIGHT,
    height: 40 + HEIGHT,
    width: '100%',
    backgroundColor: 'rgba(255,255,255,1)',
    position: 'absolute',
    top: 0,
    left: 0,
    right: 0,
    display: 'flex',
    zIndex: 99,
    justifyContent: 'flex-start',
    alignItems: 'center',
    flexDirection: 'row',
    // overflow: 'visible',
  },
  bell: {
    width: 30,
    marginLeft: 10,
  },
  free_ship: {
    width: windowWidth - 80,
    marginRight: 10,
    height: 25,
    display: 'flex',
    justifyContent: 'center',
    alignItems: 'center',
  },
  title: {
    textAlign: 'center',
    lineHeight: 26,
    color: Colors.patFontColor,
  },
  cart: {
    width: 30,
    height: 25,
    marginRight: 10,
    display: 'flex',
    justifyContent: 'center',
    alignItems: 'center',
    position: 'relative',
  },
  count: {
    position: 'absolute',
    width: 18,
    height: 18,
    fontSize: 12,
    backgroundColor: Colors.patFontRed,
    color: Colors.white,
    borderRadius: 50,
    top: -5,
    right: -5,
    textAlign: 'center',
  },
});

export default SettingTop;
